package com.example.myforum.interceptor;

import com.example.myforum.common.AppResult;
import com.example.myforum.exception.ApplicationException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

@Slf4j
@Configuration
public class LoginInterceptor implements HandlerInterceptor {

    @Override
    public boolean preHandle(
            HttpServletRequest request,
            HttpServletResponse response,
            Object handler) throws Exception {
        HttpSession session = request.getSession(false);
//        if (session == null){
//            throw new ApplicationException(AppResult.fail("当前还未登录，请登录之后了解更多~~"));
//        }
        return true;
    }
}